<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>包含自定义字体</title>
  <link href="../Styles/styles.css" rel="stylesheet" type="text/css"/>
</head>

<body>
  <h2 id="fonts">包含自定义字体</h2>

  <p class="h2subheading">— 在您的书中嵌入字体 —</p>

  <p>This tutorial shows you how to use custom fonts in your EPUB.</p>
  <p>本教程向您展示如何在 EPUB 中使用自定义字体。</p>

  <div class="tip">
    <p class="tiptext">One of the benefits of ereaders is that you can choose your own font, so it’s usually best to only use embedded fonts to highlight specific types of text – such as chapter headings, quotes, etc. – and not to change the font of the entire book.</p>
    <p class="tiptext">电子阅读器的好处之一是您可以选择自己的字体，因此通常最好只使用嵌入式字体突出显示特定类型的文本（例如章节标题，引号等），而不更改整本书里的字体。</p>
  </div>

  <p>To use a font in an EPUB you need to load the font into the EPUB, define a style for the font, and then apply the style to your text.</p>
  <p>要在 EPUB 中使用字体，您需要将该字体加载到 EPUB 中，定义该字体的样式，然后将该样式应用于文本。</p>

  <div class="tip">
    <p class="tiptext">You will need to know about stylesheets to embed fonts so you should read through the <a href="../Text/tutorial_stylesheets.html">Stylesheets</a> chapter first.</p>
    <p class="tiptext">您将需要了解有关嵌入字体的样式表，因此您应该首先阅读 <a href="../Text/tutorial_stylesheets.html">样式表</a> 一章。</p>
  </div>

  <h3 class="sigil_not_in_toc">将字体添加到您的 EPUB</h3>

  <p>To add fonts to your book, use the Add Existing Files button <img alt="document-add_22px" src="../Images/document-add_22px.png"/>. This will display a dialog allowing you to select one or more files from your computer. Select as many font files as you want.</p>
  <p>要将字体添加到书中，请使用“添加现有文件”按钮 <img alt="document-add_22px" src="../Images/document-add_22px.png"/>。这将显示一个对话框，允许您从计算机中选择一个或多个文件。选择任意数量的字体文件。</p>

  <div class="tip">
    <p class="tiptext">Many fonts are not free. Before you include fonts in your EPUB please make sure that you have a license or permission to use them. There are many free fonts available online if you search for them.</p>
    <p class="tiptext">许多字体不是免费的。在 EPUB 中包含字体之前，请确保您具有使用它们的许可证或许可。如果您要搜索，可以在线上找到许多免费字体。</p>

    <p class="tiptext">Fonts files must be either OpenType (<span class="example">.otf</span>) or TrueType (<span class="example">.ttf</span>) format. All ereaders should support <span class="example">otf</span> but most will likely support both formats.</p>
    <p class="tiptext">字体文件必须为 OpenType（<span class="example">.otf</span>）或 TrueType（<span class="example">.ttf</span>）格式。所有电子阅读器都应支持 <span class="example">otf</span>，但是大多数电子阅读器可能都支持这两种格式。</p>
  </div>

  <p>The fonts will be added to the Fonts folder in the Book Browser. However, they are not yet actually used anywhere in your book – they are just available to use.</p>
  <p>字体将被添加到“书籍浏览器”中的 Fonts 文件夹中。但是，它们尚未真正在您的书中的任何位置使用——它们仅可供使用。</p>

  <h3 class="sigil_not_in_toc" id="inserting_images">定义字体样式</h3>

  <p>Once the fonts are in your EPUB, you must define a style that includes them.</p>
  <p>字体放入 EPUB 后，您必须定义一种包含它们的样式。</p>

  <p>Add or open a stylesheet that is linked to your HTML files (see the <a href="../Text/tutorial_stylesheets.html">Stylesheets</a> chapter for more details).</p>
  <p>添加或打开链接到 HTML 文件的样式表（有关更多详细信息，请参见 <a href="../Text/tutorial_stylesheets.html">样式表</a> 一章）。</p>

  <p>Add a definition of the font, e.g.:</p>
  <p>添加字体的定义，例如：</p>

  <pre class="example">@font-face {
    font-family: 'Garamond';
    font-weight: normal;
    font-style: normal;
    src: url('../Fonts/Garamond.ttf');
}

@font-face {
    font-family: 'Garamond';
    font-weight: bold;
    font-style: normal;
    src: url('../Fonts/Garamond Bold.ttf');
}

@font-face {
    font-family: 'Garamond ;
    font-weight: normal;
    font-style: italic;
    src: url('../Fonts/Garamond Italic.ttf');
}</pre>

  <div class="tip">
    <p class="tiptext">Font names are case-sensitive!</p>
    <p class="tiptext">字体名称区分大小写！</p>

    <p class="tiptext">You must define one @font-face rule for each style of font (normal, bold, italics, etc.).</p>
    <p class="tiptext">您必须为每种字体样式（普通，粗体，斜体等）定义一个@font-face 规则。</p>

    <p class="tiptext">When using the name of a font-family the font name must either be quoted or unquoted every time you use it – you cannot mix quoted and unquoted names. Always using quotes around the font name makes things more consistent and avoids having to check if a name is valid without quotes.</p>
    <p class="tiptext">使用字体系列名称时，每次使用时，字体名称都必须加引号或不加引号–您不能混合使用带引号和未加引号的名称。始终在字体名称周围使用引号可以使内容更加一致，并且避免必须检查名称是否有效（不带引号）。</p>
  </div>

  <p>The font still isn’t actually being used in the book yet, that’s the next step.</p>
  <p>字体仍未真正在书中使用，下一步才是。</p>

  <h3 class="sigil_not_in_toc">将字体套用至文字</h3>

  <p>To make use of the font you need to create another style that you will then assign to sections of your text.</p>
  <p>要使用字体，您需要创建另一种样式，然后将其分配给文本的各个部分。</p>

  <p>So, for example, to use your new font for headings, define the style for the heading tag as follows:</p>
  <p>因此，例如，要将新字体用作标题，请按以下方式定义标题标签的样式：</p>

  <pre class="example">h1 { 
    font-family: 'Garamond', serif;
}</pre>

  <p>Or to certain paragraphs:</p>
  <p>或某些段落：</p>

  <pre class="example">p.longhand { 
    font-family: 'Garamond', serif;
    font-style: italic;
}</pre>

  <p>Or if you want, although it’s not recommended, you can apply the font to all text in the book:</p>
  <p>或者，尽管不建议这样做，但如果您需要的话，可以将字体应用于书中的所有文本：</p>

  <pre class="example">body { 
    font-family: 'Garamond', serif;
    font-weight: bold;
}</pre>

  <div class="tip">
    <p class="tiptext">The font-family rules above instruct the ereader to use your font if possible for the text, but if it’s not possible use a generic serif font.</p>
    <p class="tiptext">上面的字体系列规则会指示电子阅读器在可能的情况下为文本使用字体，但在不可能的情况下，请使用通用的衬线字体。</p>
  </div>

  <h3 class="sigil_not_in_toc">字体混淆</h3>

  <p>When you use a font in an EPUB, the font file could be extracted by someone and used somewhere else. If your fonts are licensed you may want to prevent this.</p>
  <p>当您在 EPUB 中使用字体时，该字体文件可能会被某人提取并在其他地方使用。如果您的字体获得许可，则可能要防止这种情况。</p>

  <p>You can use Sigil’s font obfuscation menu to scramble the font file using one of two standard methods, Adobe or IDPF – which one is up to you, but you should test on your target ereader to make sure the font is still readable. Obfuscation is not encryption – it just modifies the font file making it hard to use elsewhere while still being useable by readers to display fonts.</p>
  <p>您可以在 Sigil 的字体混淆菜单里使用 Adobe 或 IDPF 这两种标准方法之一来扰乱字体文件，这是您所需要的，但是您应该在目标电子阅读器上进行测试，以确保字体仍然可读。模糊处理不是加密——只是修改字体文件，使其难以在其他地方使用，同时仍可供读者显示字体。</p>

  <p>To use font obfuscation, right-click on your fonts in the Book Browser window, right-click and select Font Obfuscation from the menu and choose a method to use for obfuscation.</p>
  <p>要使用字体混淆，请在“书本浏览器”窗口中右键单击字体，右键单击并从菜单中选择“字体混淆”，然后选择用于混淆的方法。</p>

  <div class="image">
    <img alt="tutorial-font-obfuscate" src="../Images/tutorial-font-obfuscate.png"/>
  </div>

  <h3 class="sigil_not_in_toc">测试字体</h3>

  <p>Not all devices will show embedded fonts. Even Sigil may not show all your embedded fonts. Its best to test on your target device to check if your fonts are displayed as you expect.</p>
  <p>并非所有设备都会显示嵌入式字体。甚至 Sigil 可能也不会显示所有嵌入式字体。最好在目标设备上进行测试，以检查字体是否按预期显示。</p>
</body>
</html>